#!/usr/bin/env python
# -*- coding: utf-8 -*-
#

from openchord.help import logging

#### ---- test root logger ---- ####

def test_one() :
    logger = logging.getLogger()
    logger.info('==== testing Category:Root begin ====')
    logger.error('ERROR Logging Messsage.')
    logger.warn('WARN Logging Messsage.')
    logger.info('INFO Logging Messsage.')
    logger.debug('DEBUG Logging Messsage.')
    logger.trace('TRACE Logging Messsage.')
    logger.info('==== testing Category:Root   end ====')

    logger = logging.getLogger('CHORD')
    logger.info('==== testing Category:CHORD begin ====')
    logger.error('ERROR Logging Messsage.')
    logger.warn('WARN Logging Messsage.')
    logger.info('INFO Logging Messsage.')
    logger.debug('DEBUG Logging Messsage.')
    logger.trace('TRACE Logging Messsage.')
    logger.info('==== testing Category:CHORD   end ====')

test_one()

configure = '''
logging.rootLogger = DEBUG, A1, A2
logging.appender.A1 = ConsoleAppender
logging.appender.A1.layout = NotImplemented
logging.appender.A2 = FileAppender
logging.appender.A2.file = /tmp/test-chord.log
logging.appender.A2.layout = NotImplemented
'''
logging.configure( configure )

test_one()

configure += '''
logging.logger.CHORD = TRACE, A2
'''
logging.configure( configure )

test_one()

configure = '''
logging.rootLogger = DEBUG, A2
logging.appender.A2 = FileAppender
logging.appender.A2.file = /tmp/test-chord.log
logging.appender.A2.rolling = daily
logging.appender.A2.layout = NotImplemented
'''
logging.configure( configure )

test_one()

configure = '''
logging.rootLogger = DEBUG, A2
logging.appender.A2 = FileAppender
logging.appender.A2.file = /tmp/test-chord.log
logging.appender.A2.rolling = hourly
logging.appender.A2.layout = NotImplemented
'''
logging.configure( configure )

test_one()

